package org.lboot.flow.test.service;

import cn.hutool.core.thread.ThreadUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.lboot.flow.event.FlowEventConsumer;
import org.lboot.flow.event.FlowEventConsumerMeta;
import org.lboot.flow.module.event.FlowCustomEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

@Slf4j
@Service
@AllArgsConstructor
public class FormCheckEventConsumer2 implements FlowEventConsumer {
    @Resource
    ApplicationContext context;
    @Override
    public String eventId() {
        return "pre-check";
    }

    @Override
    public String consumerId() {
        return "test-consumer-2";
    }
    @Override
    public String consumerName() {
        return "预检查实现1";
    }

    @Override
    public Map<String, Object> syncConsume(FlowCustomEvent event) {
        log.info("pre-check 同步消费");
        return null;
    }

    @Override
    public void asyncConsume(FlowCustomEvent event) {
        ThreadUtil.safeSleep(1000);
        log.info("pre-check 异步步消费");
    }


    @Override
    public FlowEventConsumerMeta meta() {
        return new FlowEventConsumerMeta();
    }
}
